﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IntenseFall : Ship
{
    public ParticleSystem m_Rage;
    public AudioSource m_RageAudio;
    bool m_IsOpen = false;

    float m_DurationTimeCount = 0;
    float m_DurationTimeMax = 3.5f;
    float m_CoolingTimeCount = 2;
    float m_CoolingTimeMax = 2f;

    protected new void Start()
    {
        base.Start();
    }

    // Update is called once per frame
    protected new void Update()
    {
        base.Update();
        if (m_CoolingTimeCount < m_CoolingTimeMax)
            m_FireLicense = false;
        else
            m_FireLicense = true;
        m_CoolingTimeCount += Time.deltaTime;

        if (!m_IsOpen)
            return;

        if (m_IsOpen)
        {
            m_DurationTimeCount += Time.deltaTime;
            if (m_DurationTimeCount > m_DurationTimeMax)
            {
                m_DurationTimeCount = 0;
                m_IsOpen = false;
                var main = m_Rage.main;
                main.loop = false;
                ShotVelocityMutiple -= 1f;
                m_CoolingTimeCount = 0;
            }
        }
    }

    public override bool LaunchSkill()
    {
        if (!base.LaunchSkill())
            return false;

        ShotVelocityMutiple += 1f;
        var main = m_Rage.main;
        main.loop = true;
        m_Rage.Play();
        m_IsOpen = true;
        m_RageAudio.Play();
        return true;
    }
    public override void OnChase()
    {
        if (SkillIsReady)
            LaunchSkill();
    }
    public override void OnFight()
    {
        if (SkillIsReady)
            LaunchSkill();
    }
    public override void OnRetreat()
    {
    }
}
